import { ApiCall } from "tsrpc";
import { ReqGetPoss, ResGetPoss } from "../../shared/protocols/Get/PtlGetPoss";
import { Global } from '../../Global/index';

export default async function (call: ApiCall<ReqGetPoss, ResGetPoss>) {
    // TODO
    const user = call.currentUser
    const courseid = call.req.courseId

    const course = await Global.collection('courses').findOne({
        _id:courseid,
        teacher:user._id
    })

    call.succ({
        poss:Boolean(course)
    })
}